import couponApi from "@/api/declaration/mall/couponApi"
import httpRequest from "@/config/axios/httpRequest"
import { CouponTemplateModel } from "@/models/mall/CouponTemplateModel"


// 创建优惠劵模板
export function createCouponTemplate(data: CouponTemplateModel) {
  return httpRequest.post(couponApi.CreateCouponTemplate, data)
}

// 更新优惠劵模板
export function updateCouponTemplate(data: CouponTemplateModel) {
  return httpRequest.put(couponApi.UpdateCouponTemplate, data)
}

// 更新优惠劵模板的状态
export function updateCouponTemplateStatus(id: number, status: [0, 1]) {
  const data = {
    id,
    status
  }
  return httpRequest.put(couponApi.UpdateCouponTemplateStatus, data)
}

// 删除优惠劵模板
export function deleteCouponTemplate(id: number) {
  return httpRequest.delete(couponApi.DeleteCouponTemplate, {params: {id}})
}

// 获得优惠劵模板
export function getCouponTemplate(id: number) {
  return httpRequest.get(couponApi.GetCouponTemplate, {params: {id}})
}

// 获得优惠劵模板分页
export function getCouponTemplatePage(params: PageParam) {
  return httpRequest.get(couponApi.GetCouponTemplatePage, {params})
}

// 获得优惠劵模板分页
export function getCouponTemplateList(ids: number[]) {
  return httpRequest.get(couponApi.GetCouponTemplateList, {params: {ids}})
}

// 导出优惠劵模板 Excel
export function exportCouponTemplateExcel(params: PageParam) {
  return httpRequest.download(couponApi.ExportCouponTemplateExcel, {params})
}
